import cv2
import numpy as np


# events = [i for i in dir(cv2) if 'EVENT' in i]
# print(events)

# cv2_EVENT_MOUSEMOVE 0 滑动 
# cv2_EVENT_LBUTTONDOWN 1 左键点击 
# cv2_EVENT_RBUTTONDOWN 2 右键点击 
# cv2_EVENT_MBUTTONDOWN 3 中间点击 
# cv2_EVENT_LBUTTONUP 4 左键释放 
# cv2_EVENT_RBUTTONUP 5 右键释放 
# cv2_EVENT_MBUTTONUP 6 中间释放 
# cv2_EVENT_LBUTTONDBLCLK 7 左键双击 
# cv2_EVENT_RBUTTONDBLCLK 8 右键双击 
# cv2_EVENT_MBUTTONDBLCLK 9 中间释放
#
# cv2_EVENT_FLAG_LBUTTON 1 左键拖拽  
# cv2_EVENT_FLAG_RBUTTON 2 右键拖拽  
# cv2_EVENT_FLAG_MBUTTON 4 中间拖拽  
# cv2_EVENT_FLAG_CTRLKEY 8 (8~15)按Ctrl不放事件  
# cv2_EVENT_FLAG_SHIFTKEY 16  (16~31)按Shift不放事件  
# cv2_EVENT_FLAG_ALTKEY 32  (32~39)按Alt不放事件



def draw_circle(event, x, y, flags, param):
    if event == cv2.EVENT_LBUTTONDBLCLK:
        # cv2.rectangle(img, (0, 0), (x, y), (0, 255, 0), 5, 8, 0)
        cv2.circle(img, (x, y), 100, (255, 0, 0), -1)


# 创建图像与窗口并将窗口与回调函数绑定
img = np.zeros((500, 500, 3), np.uint8)
cv2.namedWindow('image')
cv2.setMouseCallback('image', draw_circle)

while (1):
    cv2.imshow('image', img)
    if cv2.waitKey(1) & 0xFF == ord('q'):  # 按q键退出
        break

cv2.destroyAllWindows()
